Skip to content

ios27/a64e: translate libcorecrypto (the S9's hottest A64E traps) and reseal its FIPS seal; a64e census + log/verify/restore - #384

Merged
claudiusthebot merged 1 commit into
mainfrom
agent/scion-a64e-fix/corecrypto-seal
Nov 18, 2026
Merged

claudiusthebot merged 1 commit into
mainfrom
agent/scion-a64e-fix/corecrypto-seal

Conversation

@claudiusthebot

Copy link
Copy Markdown
Collaborator

What

The S9's hottest arm64e traps on iOS 27.2.1 (24B156) are all in /usr/lib/system/libcorecrypto.dylib. The cache pipeline skipped that library (--skip libcorecrypto) because corecrypto's FIPS self-test MACs its own code, so its 3,538 pointer-auth words (1,500 RETA*, 67 BRA*, 1,312 BLRA*, 659 PAC*/AUT* register forms) went through the kernel's emulation on every call.

Evidence (phone 1, o272, root v9, console log con-xnu-boot-p8-metal-passes.log):

  • STARLTE A64E hot sites 0x1d919fc5c and 0x1d919fbe0 (RETAB d65f0fff) took 106,512 and 104,880 traps in one 10 s interval at 16:18:50 while iconservicesagent re-rendered icons after a dark-mode switch, and 2,000-15,000 per 10 s at idle. More sites: d63f091f (BLRAAZ x8), d73f0a11 (BLRAA x16, x17), d61f08bf (BRAAZ x5).
  • The addresses are slid: the boot with slide 0x63a8000 shows the same site as 0x1da0a3c5c, the one with slide 0x54a4000 as 0x1d919fc5c; both are 0x1d3cfbc5c unslid.
  • Unslid, every hot site is in libcorecrypto.dylib __TEXT,__text. The hottest pair is the return of ccder_blob_decode_range and of the local function after it, then ccder_sizeof and some local functions. The hot LSE site 0x1d919e77c is the library's only SWP (b8298100, unslid 0x1d3cfa77c).
  • Nothing was wrong with the encodings or the sections the tool scans. The library was skipped on purpose.

The fix

corecrypto's integrity check (fipspost_get_hmac.c) computes HMAC-SHA256 with a key of 32 zero bytes over the image's __TEXT,__text and compares it with __TEXT,__fips_hmacs. On the 24B156 cache the stored value is exactly that HMAC, so it can be recomputed for the rewritten code.

  • tools/ios27/a64e/fips-seal.py check|reseal|restore. It reseals only an image whose seal was true in the reference (stock) cache and whose stored value is still the reference one. Each reseal is logged and can be restored. Pure Python.
  • tools/ios27/a64e/fips-seal-test.py, also run in CI: made-up Mach-O files covering sealed, broken after rewrite, dry run, reseal, a change after the reseal, refusal of a moved seal, restore, and a seal that was already false.
  • a64e-rewrite.py:
    • cache --log writes ADDR OLD NEW for every changed word; verify and restore work from that log (the same round trip as lse-rewrite.py).
    • census lists, per image, the words the rewrite would still change, with nothing skipped, and exits 1 unless the image is allowed. On the v9 cache it flags exactly the three corecrypto images out of 4,759, so it would have caught this.
  • cache-pipeline.sh:
    • steps 1, 2 and 4 now skip only the unloaded libcorecrypto_noasm/_trace (their seals are false in the stock cache already);
    • new step 5b reseals and checks, before the grow step's PRE reference;
    • new step 9 runs the census.
  • The LSE pass needs TEXTDATA_SKIP here (the pipeline sets it): two SHA-256 K words (78a5636f) in corecrypto's __text decode as LDUMAXAH.
  • Docs: docs/ios27/CORECRYPTO.md (new), INSTALL-S9.md, SPEED.md.

Nothing Apple-derived is in the repo, only tools and docs.

Tests

  • On the mini (M1):
    • fips-seal-test.py: all ok.
    • lse/test/run.sh: 5/5 STRESS OK. The 28 diff lines are all the documented Rs==Rn cases.
    • a64e-rewrite.py census on the v9 cache flags the 3 corecrypto images, and only the 2 allowed variants after the step.
  • Root step on a clone of root v9 (private, on the mini):
    • 3,538 words rewritten, and verify reports 3538 ok;
    • the SWP got a thunk, lse verify reports 1 ok, and the 2 table words were left alone;
    • reseal, then check reports sealed;
    • exactly 3,560 words of subcache .21 and 4 of .19 differ from v9.
    • textdata-guard.py scan --pac flagged 6 of the changed words by rule D. I reviewed all 6 and they are ordinary code.
  • The full cache-pipeline.sh run was not repeated from a stock cache. The changed steps were run one by one on the v9 root.
  • Preflight: this repository has no package.json/npm run preflight. I ran the CI steps that apply locally: py_compile, provenance-check, docs-check and fips-seal-test.
  • Phone A/B: see the comments.

🤖 Generated with Claude Code

…and log/verify/restore for a64e-rewrite

The S9's hottest A64E traps on 24B156 (~100k RETAB traps per 10 s while iconservicesagent re-renders icons
after a dark-mode switch, thousands at idle) are all in /usr/lib/system/libcorecrypto.dylib, which the cache
pipeline skipped because its FIPS self-test MACs its own __text. That MAC is HMAC-SHA256 with an all-zero key
over __TEXT,__text, stored in __TEXT,__fips_hmacs (apple/corecrypto fipspost_get_hmac.c), so it can be
recomputed for the rewritten code.

- a64e/fips-seal.py check|reseal|restore: recompute the seal only where it was true in the reference
  (stock) cache and the stored value is still the reference one; logged, restorable. Pure Python.
- a64e/fips-seal-test.py (CI): made-up Mach-O files; sealed, broken, reseal, restore, refusals.
- a64e-rewrite.py: cache --log (ADDR OLD NEW), verify/restore from the log, and census: per image the
  words the rewrite would still change, nothing skipped; exit 1 unless allowed.
- cache-pipeline.sh: steps 1/2/4 skip only the unloaded libcorecrypto_noasm/_trace; 5b reseal + check;
  9 census.
- docs/ios27/CORECRYPTO.md; INSTALL-S9.md and SPEED.md updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@claudiusthebot
claudiusthebot merged commit 36e501f into main Nov 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant